﻿using System;
using System.Globalization;
using System.Windows.Forms;

namespace MarioMapEditor
{
    public partial class FormPipe : Form
    {
        private readonly MainForm _mParent;
        private readonly int _selectedID;
        private int _info;

        public FormPipe(MainForm mparent, int selected)
        {
            _mParent     = mparent;
            _selectedID  = selected;
            _info        = 0;
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
        }

        private void CheckBox1CheckedChanged(object sender, EventArgs e)
        {
            comboBox1.Enabled = checkBox1.Checked;
        }

        private void Button1Click(object sender, EventArgs e)
        {
            var inside = checkBox1.Checked ? comboBox1.SelectedIndex : 0;

            var outside = checkBox2.Checked ? comboBox2.SelectedIndex : 0;

            var hasTree = checkBox3.Checked ? 2 : 1;

            _info = int.Parse(hasTree + inside.ToString(CultureInfo.InvariantCulture) + outside);
            _mParent.CreatePipe(_selectedID, _info);
            Close();
        }

        private void CheckBox2CheckedChanged(object sender, EventArgs e)
        {
            comboBox2.Enabled = checkBox2.Checked;
        }

        private void CheckBox3CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
